package com.rain.cy.business.controller;

import com.rain.cy.business.model.dto.DoctorCountDataDTO;
import com.rain.cy.business.model.dto.PatientCountDataDTO;
import com.rain.cy.business.service.CountService;
import com.rain.cy.business.service.DictionaryService;
import com.rain.cy.business.service.PatientCountService;
import com.rain.cy.business.service.UserFeedbackService;
import com.rain.cy.framework.entity.BaseController;
import com.rain.cy.framework.result.Result;
import com.rain.cy.framework.result.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author yu_chen
 * @since 2021/10/7 15:43
 */
@RestController
@RequestMapping("api/count")
public class CountController extends BaseController {


    @Autowired
    private CountService countService;

    @Autowired
    private PatientCountService patientCountService;
    @Autowired
    private DictionaryService dictionaryService;

    @Autowired
    private UserFeedbackService userFeedbackService;


    @GetMapping("/data/doctor")
    @ApiOperation(value = "医生数据统计", response = Result.class, notes = "yu_chen")
    public Result getDoctorCount() {
        Integer currentUserId = getCurrentUserId();
        DoctorCountDataDTO doctorCountDataDTO = DoctorCountDataDTO.builder()
                .innerUsersCount(countService.getCurrentUserNumInnerOrOuter(currentUserId, true))
                .outerUsersCount(countService.getCurrentUserNumInnerOrOuter(currentUserId, false))
                .userFeedbackCount(countService.getUserFeedbackCount(currentUserId))
                .userFeedbackTags(dictionaryService.getUserFeedBackTag())
                .drugCount(countService.getDrugLeftCount(currentUserId))
                .userFeedbackMapList(userFeedbackService.getUserFeedbackMapList(currentUserId))
                .build();
        return ResultUtil.success(doctorCountDataDTO);
    }


    @GetMapping("/data/patient")
    @ApiOperation(value = "患者数据统计", response = Result.class, notes = "yu_chen")
    public Result getPatientCount() {
        Integer currentUserId = getCurrentUserId();
        PatientCountDataDTO patientCountDataDTO = PatientCountDataDTO.builder()
                .actionCount(patientCountService.getActionCount(currentUserId))
                .scoreCount(patientCountService.getScoreCount(currentUserId))
                .build();
        return ResultUtil.success(patientCountDataDTO);
    }

}
